<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增录播课程')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css" /> 
    <link rel="stylesheet" href="/colorpicker/bootstrap-colorpicker.css"/>
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-video-add">
            <div class="form-group col-sm-6">    
                <label class="col-sm-4 control-label is-required">栏目编码：</label>
                <div class="col-sm-8">
                    <div class="input-group" onclick="selectVideocategoryTree()">
                        <input id="treeId" name="categoryId" type="hidden" />
                        <input readonly="readonly"  class="form-control" type="text"  id="treeName"  required>
                        <span class="input-group-addon" ><i class="fa fa-search"></i></span>
                    </div>                
                </div>
            </div>
            
            <div class="form-group col-sm-6">    
                <label class="col-sm-4 control-label">推荐位：</label>
                <div class="col-sm-8">
                    <select name="dictPostPositions" class="form-control m-b" th:with="type=${@dict.getType('dict_post_positions')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>            
		<div class="row">
            <div class="form-group col-sm-12">    
                <label class="col-sm-2 control-label is-required">标题：</label>
                <div class="col-sm-10">
								<div class="input-group">
									<input name="title"  class="form-control " type="text" required />
									<span class="input-group-btn">
										 <span class="input-group input-color " data-color-format="hex">
											<span class="input-group-addon" style="border-radius:0;border-left:0;">
												<i style="background-color:#343036"></i>
											</span>
											<input name="color" style="width:80px;"  placeholder="标题颜色"  class="form-control" type="text">
										</span>
									</span>
								</div>
                </div>
            </div>            

           
        </div>    
          <div class="row">    
            <div class="form-group  col-sm-12">
                <label class="col-sm-2 control-label"><span class="help-block m-b-none"><i class="fa fa-info-circle" title="请用逗号分割标签"></i> 标签：</span> </label>
                <div class="col-sm-10">
                   <input name="tags" id="tags"  type="hidden" required>
                   <select class="js-example-tags form-control" id="tagsselect" name="tagsselect"  required> 
  				   </select>
                </div>
            </div>
         
          </div>
          
           <div class="row">  
            <div class="form-group col-sm-12">
                <label class="col-sm-2 control-label">外部链接：</label>
                <div class="col-sm-10">
               		<input name="href" type="url" class="form-control"   />
                </div>
            </div>
        </div>    
		<div class="row">        
            <div class="form-group  col-sm-12">
                <label class="col-sm-2 control-label">关键字：</label>
                <div class="col-sm-10">
                    <textarea name="keywords" class="form-control" required></textarea>
                </div>
            </div>
		</div>    
		
		<div class="row">        
            <div class="form-group  col-sm-12">
                <label class="col-sm-2 control-label">描述：</label>
                <div class="col-sm-10">
                   <textarea name="description" class="form-control" required></textarea>
                </div>
            </div>
		</div>     		
          
        <div class="row">  
            <div class="form-group  col-sm-6">
                <label class="col-sm-4 control-label">授课讲师：</label>
                <div class="col-sm-8">
                  
                    <select name="videoTeacherIds" class="form-control m-b" th:with="listTearcher=${cmsVideo.listTeacher}">
                        <option th:each="tearcher : ${listTearcher}" th:text="${tearcher.name}" th:value="${tearcher.id}"></option>
                    </select>                    
                    
                </div>
            </div>


            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label">展示策略：</label>
                <div class="col-sm-8">
                    <select name="dictShowStrategy" class="form-control m-b" th:with="type=${@dict.getType('dict_show_strategy')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label">会员策略：</label>
                <div class="col-sm-8">
                    <select name="dictVipStrategy" class="form-control m-b" th:with="type=${@dict.getType('dict_vip_strategy')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group  col-sm-6">    
                <label class="col-sm-4 control-label">是否允许套餐：</label>
                <div class="col-sm-8">
                    <select name="dictIsPackage" class="form-control m-b" th:with="type=${@dict.getType('dict_is_package')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group  col-sm-6">    
                <label class="col-sm-4 control-label">是否允许优惠券：</label>
                <div class="col-sm-8">
                    <select name="dictIsCoupon" class="form-control m-b" th:with="type=${@dict.getType('dict_is_coupon')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            
   			<div class="form-group   col-sm-6">    
                <label class="col-sm-4 control-label">内容视图：</label>
                <div class="col-sm-8">
                    <select name="dictContentView" class="form-control m-b" th:with="type=${@dict.getType('dict_content_view')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>            
          </div>   
         <div class="row">          
            
            <div class="form-group  col-sm-6">    
                <label class="col-sm-4 control-label">市场价：</label>
                <div class="col-sm-8">
                    <input name="maxPrice" class="form-control number" type="text" required>
                </div>
            </div>
            <div class="form-group  col-sm-6">    
                <label class="col-sm-4 control-label">销售价：</label>
                <div class="col-sm-8">
                    <input name="price" class="form-control number" type="text" required>
                </div>
            </div>
            <div class="form-group  col-sm-6">    
                <label class="col-sm-4 control-label">销售数量：</label>
                <div class="col-sm-8">
                    <input name="saleNumber" class="form-control number" type="text" required>
                </div>
            </div>
          
           <div class="form-group col-sm-6">    
                <label class="col-sm-4 control-label">点击数：</label>
                <div class="col-sm-8">
                    <input name="hits" class="form-control number" type="text" required>
                </div>
            </div>
            <div class="form-group  col-sm-6">    
                <label class="col-sm-4 control-label">收藏数：</label>
                <div class="col-sm-8">
                    <input name="collectionCount" class="form-control number" type="text" required>
                </div>
            </div>

            <div class="form-group  col-sm-6">    
                <label class="col-sm-4 control-label">排序：</label>
                <div class="col-sm-8">
                    <input name="sort" class="form-control number" type="text" required>
                </div>
            </div>     
      </div>  
            
            <div class="form-group  col-sm-12">    
                <label class="col-sm-2 control-label">封面：</label>
                <div class="col-sm-10">
                    <input type="hidden" name="image">
                    <div class="file-loading">
                        <input class="form-control file-upload-image" id="image" name="file" type="file">
                    </div>
                </div>
            </div>
         
            <div class="form-group  col-sm-12">    
                <label class="col-sm-2 control-label">视频：</label>
                <div class="col-sm-10">
                     <input type="text" class="form-control"  name="video"><br/>
                    <div class="file-loading">
                        <input class="form-control file-upload-video" id="video" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group  col-sm-12">    
                <label class="col-sm-2 control-label">视频时长：</label>
                <div class="col-sm-10">
                    <input name="videoTimes" class="form-control" type="text">
                </div>
            </div>
             <div class="form-group col-sm-12">    
                <label class="col-sm-2 control-label">课程资料：</label>
                <div class="col-sm-10">
                    <input type="hidden" name="videoAttachment">
                    <div class="file-loading">
                        <input class="form-control file-upload-videoAttachment" id="videoAttachment" name="file" type="file">
                    </div>
                </div>
            </div>  

            <div class="form-group  col-sm-12">    
                <label class="col-sm-2 control-label">内容：</label>
                <div class="col-sm-10">
                    <input type="hidden" class="form-control" id="cmsVideoData.content" name="cmsVideoData.content">
                     <div id="editor" class="summernote"></div>
                </div>
            </div>


        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <th:block th:include="include :: summernote-js" />    
    <script src="/colorpicker/bootstrap-colorpicker.js"></script>
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
    $("#form-video-add .input-color").colorpicker();
        var prefix = ctx + "ecms/video"
        $("#form-video-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
        	var sHTML = $('.summernote').summernote('code');
        	$("#cmsVideoData\\.content").val(sHTML);
        	$('#tags').val($('#tagsselect').select2('val'));
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-video-add').serialize());
            }
        }

        
        $(".file-upload-image").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            allowedFileTypes: ['image'],
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })

        $(".file-upload-videoAttachment").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            allowedFileTypes: ['object'],
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
        
        
        $(".file-upload-video").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            allowedFileTypes: ['video' ],
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })        
          
             
        
        
        $(function() {
            $('.summernote').summernote({
                lang: 'zh-CN',
                dialogsInBody: true,
                callbacks: {
                    onChange: function(contents, $edittable) {
                        $("input[name='" + this.id + "']").val(contents);
                    },
                    onImageUpload: function(files) {
                        var obj = this;
                    	var data = new FormData();
                    	data.append("file", files[0]);
                    	$.ajax({
                            type: "post",
                            url: ctx + "common/upload",
                    		data: data,
                    		cache: false,
                    		contentType: false,
                    		processData: false,
                    		dataType: 'json',
                    		success: function(result) {
                    		    if (result.code == web_status.SUCCESS) {
                    		        $('#' + obj.id).summernote('insertImage', result.url);
                    		    } else {
                    		        $.modal.alertError(result.msg);
                    		    }
                    		},
                    		error: function(error) {
                    		    $.modal.alertWarning("图片上传失败。");
                    		}
                    	});
                    }
                }
           
            });
        });
    </script>
    <script type="text/javascript">
    /*视频分类-新增-选择父视频分类树*/
    function selectVideocategoryTree() {
        var options = {
            title: '视频分类选择',
            width: "380",
            url:  ctx + "ecms/videocategory" + "/selectVideocategoryTree/" + $("#treeId").val(),
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }
    
    function doSubmit(index, layero){
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }  
    $('.summernote').summernote({
        placeholder: '', //为空时的提示内容
        height: 300,               //编辑器高度
        minHeight: 300,             // 最小高度
        maxHeight: 1500,             // 最大高度
    });
    </script>    

   
    <script type="text/javascript">
    /*视频分类-新增-选择父视频分类树*/
    function selectVideocategoryTree() {
        var options = {
            title: '视频分类选择',
            width: "380",
            url:  ctx + "ecms/videocategory" + "/selectVideocategoryTree/" + $("#treeId").val(),
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }
    
    function doSubmit(index, layero){
        var body = $.modal.getChildFrame(index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        $.modal.close(index);
    }   
    </script>

	<script type="text/javascript">
	$("#tagsselect").select2({
		tokenSeparators: [',', ' '], 
		placeholder:'请您录入标签然后回车',
		tags: true,
		theme: "bootstrap",
	    multiple: true, 
	});
	</script>   
</body>
</html>